Template.header_messages.onCreated(function () {
  Session.set('class.messages.modalContent', 'messages');
});

Template.header_messages.onRendered(function () {
  $('[data-toggle="tooltip"]').tooltip({
    trigger: "hover"
  });
});

Template.header_messages.helpers({
  modalContent() {
    return Session.get('class.messages.modalContent');
  },
});

Template.header_messages.events({
  'click .message-modal-header-button' (event) {
    event.preventDefault();
    if (isMobile()) {
      console.log("navigator to a page.");
    } else {
      $("#message-modal").modal();
    }
  },
  'click .go-messages-search' (event, instance) {
    Session.set('class.messages.modalContent', 'messages_search');
  },
  'click .go-messages' (event, instance) {
    Session.set('class.messages.modalContent', 'messages');
  },
  'click .go-chatroom' (event, instance) {
    Session.set('class.messages.modalContent', 'messages_chatroom');
  }
});